from django.db import models
from rest_framework import serializers


# Create your models here.python manage.py makemigrations

class Notice(models.Model):
    content = models.TextField('公告内容')
    publish_time = models.DateTimeField('发布时间', auto_now_add=True)
    update_time = models.DateTimeField('更新时间', auto_now=True)
    is_deleted = models.BooleanField('是否删除', default=False)

    class Meta:
        db_table = 'sys_notice'  # 指定表名
        verbose_name = '公告信息'
        verbose_name_plural = '公告信息'
        ordering = ['-publish_time']  # 默认按发布时间倒序排列


class SysNoticeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notice
        fields = "__all__"
